package com.example.projectcode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.projectcode.mapper.TestcomprehensiveMapper;
import com.example.projectcode.model.Testcomprehensive;
import com.example.projectcode.service.TestcomprehensiveService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestcomprehensiveServiceImpl extends ServiceImpl<TestcomprehensiveMapper, Testcomprehensive> implements TestcomprehensiveService {
    @Override
    public int addComprehensive(Integer testId, Integer cpId, Integer score) {
        Testcomprehensive testcomprehensive = new Testcomprehensive();
        testcomprehensive.setCpId(cpId);
        testcomprehensive.setCpScore(score);
        testcomprehensive.setTestId(testId);
        return baseMapper.insert(testcomprehensive);
    }

    @Override
    public List<Testcomprehensive> selectComprehensiveByTestId(Integer testId) {
        return baseMapper.selectList(new QueryWrapper<Testcomprehensive>().eq("testid",testId));
    }

    @Override
    public Testcomprehensive selectOneBttestCpId(Integer testCpId) {
        return baseMapper.selectOne(new QueryWrapper<Testcomprehensive>().eq("T_Cpid",testCpId));
    }
}
